home *** CD-ROM | disk | FTP | other *** search
- /*
- * Hello StdgXtra World by Loki
- *
- * An example program which shows how easy it is to program with stdgxtra.
- * The example creates a page which has a string on it.
- * There are 7 library functions and 2 variables used.
- */
-
- #include "stdg.h"
- #include "stdgxtra.h"
-
- /*
- * The window contains a text field, which is just used to display text.
- */
-
- field *f;
-
- /*
- * The resize function is called when a window is resized.
- * It should recalculate the locations and sizes of all structures.
- */
- void resize(window *w)
- {
- /*
- * The only structure we have on the window is a text field.
- * The only thing we have to do is make the field the size
- * of the window's bitmap, since we have arranged for the text
- * to be centered both vertically and horizontally.
- */
-
- f->r = w->b->r;
- }
-
- /*
- * The main function is where the program begins.
- */
- int main(int argc, char **argv)
- {
- window *w;
-
- /* Initilise the graphical interface. */
- ginit("Hello StdgXtra World", NULL, NULL);
-
- /* Create a new window which is the size of the screen. */
- w = new_window("Hello Window", rect(0,0,0,0), Titlebar|Maximize|Resize);
-
- /* Link our resize function to the window. */
- set_winfns(w, NULL, &resize, NULL);
-
- /* Create a text field and add it to the window */
- f = new_field(Center+VCenter, w->b->r, sys_font,
- "Hello, World!", GREY)
-
- add_field(w, f);
-
- /* Display the window on the screen. */
- show_window(w);
-
- /* Now poll for events but do nothing with them. */
- while(1)
- can_event();
-
- return 0;
- }
-